package com.hymall.controller.admin;

import com.hymall.bean.MarketBrand;
import com.hymall.bean.common.BasePageInfo;
import com.hymall.bean.common.BaseRespVo;
import com.hymall.bean.common.CommonData;
import com.hymall.bean.vo.BrandCreateVo;
import com.hymall.service.admin.AdminBrandService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: 周子伟
 * @description ${商场管理 品牌制造商}
 * @date: 2022/7/16 23:22
 */

@RestController
@RequestMapping("admin/brand")
public class AdminBrandController {
    @Autowired
    AdminBrandService adminBrandService;


    @GetMapping("list")
    /*
     * @author Invoker
     * @description {根据品牌商name id  实现查找功能}
     * @date
     * @param name  id   BasePageInfo
     * @return
     */
    public BaseRespVo list(String name, Integer id, BasePageInfo info) {

        CommonData data = adminBrandService.query(name, id, info);
        return BaseRespVo.ok(data);

    }

    @PostMapping("create")

    /*
     * @author Invoker
     * @description {根据用户输入信息 实现品牌商新增功能}
     * @date
     * @param  marketBrand
     * @return
     */

    public BaseRespVo create(@RequestBody MarketBrand marketBrand) {
        // TODO 写之前需要 admin/storage/create
        BrandCreateVo data = adminBrandService.create(marketBrand);

        return BaseRespVo.ok(data);
    }

  /*
   * @author Invoker
   * @description {对已有的品牌制造商信息进行修改}
   * @date
   * @param   marketBrand
   * @return
   */

    @PostMapping("update")
    public BaseRespVo update(@RequestBody MarketBrand marketBrand) {

        MarketBrand data = adminBrandService.update(marketBrand);
        return BaseRespVo.ok(data);


    }
   /*
   * @author Invoker
   * @description {删除品牌制造商信息}
   * @date
   * @param  marketBrand
   * @return
   */

    @PostMapping("delete")
    public BaseRespVo delete (@RequestBody MarketBrand marketBrand ){

        adminBrandService.delete(marketBrand);
        return BaseRespVo.ok(null);

    }



}
